<template>
  <div class="mmmmmmggg">
    <div class="screenComp">
      <div class="screenContainer1111">
        <div class="title"> 举报处理 </div>
        <!-- 关键字筛选 -->
        <div class="screenItem">
          <div class="inputCont">
            <span class="label">搜关键字：</span>
            <div class="labScach">
              <input v-model="keyWord" placeholder="请输入用户名称搜索" @input="getDetail()" />
              <search class="searchIcon" theme="outline" size="20" fill="#999"
                style="position: absolute;right: 8px;top: 9px;" />
            </div>
          </div>
          <div class="inputCont">
            <span class="label">搜关键字：</span>
            <div>
              <el-select v-model="areaId" placeholder="全部" size="large" clearable="true" @change="getDetail()">
                <el-option v-for="item in options" :key="item.id" :label="item.name" :value="item.id" />
              </el-select>
            </div>
          </div>
        </div>
      </div>
    </div>


    <div class="appMessagePage" v-loading="auditListLoading">
      <el-tabs class="demo-tabs" @tab-change="changeTabs">
        <el-tab-pane>
          <template #label>
            <span class="custom-tabs-label">
              <span class="tableCol">未回复</span>
              <i class="tableTips bgCol1"> {{ statisticsNum.waitAuditNumber > 99 ? '99+' : statisticsNum.waitAuditNumber
              }}</i>
            </span>
          </template>
        </el-tab-pane>
        <el-tab-pane>
          <template #label>
            <span class="custom-tabs-label">
              <span class="tableCol">已回复</span>
              <i class="tableTips bgCol5">{{ statisticsNum.auditPassedNumber > 99 ? '99+' :
                statisticsNum.auditPassedNumber }}</i>
            </span>
          </template>
        </el-tab-pane>

        <div class="tabContent">
          <el-table :data="tableData" :header-cell-style="{ color: '#999' }" :cell-style="{ color: '#35353F' }"
            style="width: 100%">
            <el-table-column label="序号" width="80">
              <template #default="scope">
                {{ (page - 1) * 10 + scope.$index + 1 }}
              </template>
            </el-table-column>
            <el-table-column prop="complainTitle" label="标题" width="170" />
            <el-table-column prop="addressName" label="区域" width="170" />
            <el-table-column prop="remark" label="描述" :show-overflow-tooltip="true" />
            <el-table-column prop="contactInfo" label="联系方式" width="170" />
            <el-table-column prop="createTime" label="留言时间" width="170" />
            <el-table-column prop="status" label="图片" width="140">
              <template #default="scope">
                <el-image v-if="scope.row.remarkPhoto" :preview-teleported="true" style="width: 46px; height: 26px"
                  :preview-src-list="scope.row.remarkPhoto.split(',')"
                  :src="scope.row.remarkPhoto.split(',')[0]"></el-image>
                <span v-else class="custom-tabs-label">暂无</span>
              </template>
            </el-table-column>
            <el-table-column label="操作" fixed="right" width="90">
              <template #default="scope">
                <span class="spanBtn color5" @click="feedBack(scope.row, 'edit')" v-if="currentTabIndex == 0">处理</span>
                <span class="spanBtn color1" @click="feedBack(scope.row, 'see')" v-if="currentTabIndex == 1">查看</span>
                <!-- <span class="spanBtn color2" @click="updatePictureValid(scope.row.id)">删除</span> -->
              </template>
            </el-table-column>
          </el-table>

          <div class="pagination">
            <el-pagination background layout="total, prev, pager, next, jumper"
              :total="currentTabIndex == 0 ? statisticsNum.waitAuditNumber : statisticsNum.auditPassedNumber"
              :page-size="limit" :current-page="page" @current-change="getDetail">
            </el-pagination>
          </div>
        </div>
      </el-tabs>
    </div>

    <!-- 处理备注窗口 -->
    <el-dialog :close-on-click-modal="false" v-model="feedbackContShow" width="500px" :show-close="false">
      <template #header="{ close, titleId, titleClass }">
        <div class="myDialogHeader">
          <span :id="titleId" :class="titleClass">处理备注</span>
          <div class="close">
            <close @click="close" theme="outline" size="20" fill="#666" />
          </div>
        </div>
      </template>
      <div class="fromLabel">
        <div class="labelItem" style="width: 100%; margin-bottom: 2px">
          <div class="term fromFlex">
            <div class="label">处理备注内容</div>
            <div>
              <el-input size="large" type="textarea" resize="none" :autosize="{ minRows: 8 }" v-model="adminRemark"
                maxlength="200" show-word-limit placeholder="请输入处理内容" clearable :readonly="feedBackEditType == 'see'" />
            </div>
          </div>
        </div>

        <div class="labelBtn" v-if="feedBackEditType == 'edit'">
          <div class="btn default" @click="feedbackContShow = !feedbackContShow">取消</div>
          <div class="btn info" @click="replyComplaint">确认处理完毕</div>
        </div>
      </div>
    </el-dialog>
  </div>
</template>
<script>
import { ElMessage, ElMessageBox } from 'element-plus'

export default {
  name: 'contentManagementMessageManager',
  components: {},
  data() {
    return {
      auditListLoading: false,
      page: 1,
      limit: 10,
      keyWord: '',
      areaId: '',
      currentTabIndex: 0,
      options: [],
      tableData: [],
      statisticsNum: {},
      activeButtonIndex: 0,
      feedbackContShow: false,
      feedBackEditType: 'edit',
      newId: '',
      adminRemark: '',

      updateId: '',
      str: '',
      input2: '镇',
      dialog2: false,
      radio: '1',
      deleteId: '',
      type: 1,
      titleName: '',
      list1: [],
    }
  },
  created() {
    this.getDetail()
    this.getSelectAllAreaInfoList()
    this.getStatisticsTotalNumber()
  },
  methods: {
    // 数据列表
    getDetail(page) {
      if (page) {
        this.page = page
      }
      this.auditListLoading = true
      this.$http
        .post('/axh/complaint/list', {
          currentStatus: this.currentTabIndex,
          keyWord: this.keyWord,
          areaId: this.areaId,
          page: this.page,
          limit: this.limit,
        })
        .then((res) => {
          this.tableData = res.result
          this.auditListLoading = false
        })
    },
    // 区域查询
    getSelectAllAreaInfoList() {
      this.$http
        .post('/axh/complaint/selectAllAreaInfoList')
        .then((res) => {
          if (res && res.result) {
            this.options = res.result
          }
        })
    },
    // 投诉数量
    getStatisticsTotalNumber() {
      this.$http
        .post('/axh/complaint/statisticsTotalNumber')
        .then((res) => {
          if (res && res.result) {
            this.statisticsNum = res.result
          }
        })
    },
    // 状态tab切换
    changeTabs(e) {
      this.currentTabIndex = e
      this.getDetail(1)
    },
    // 操作按钮 
    feedBack(item, faly) {
      this.newId = item.id
      this.feedBackEditType = faly
      this.feedbackContShow = true
      this.adminRemark = item.processRemark
    },
    // 回复投诉意见
    replyComplaint() {
      this.$http
        .post('/axh/complaint/deal', {
          id: this.newId,
          processRemark: this.adminRemark,
        })
        .then((res) => {
          if (res && res.msg) {
            ElMessage.success('操作成功')
            this.feedbackContShow = false
            this.getDetail()
            this.getStatisticsTotalNumber() 
          }
        })
    },



    selectButton(buttonIndex) {
      this.activeButtonIndex = buttonIndex // 更新选中的按钮索引
      const buttonId = this.list1[buttonIndex].id
      this.getDetail(buttonId) // 处理点击事件
    },
    update1() {
      this.$http
        .post('axh/newType/updateType', {
          id: this.updateId,
          name: this.str,
        })
        .then((res) => {
          this.str = ''
          this.dialog2 = false
          this.getDetail()
        })
    },
    setStr(row) {
      this.str = row.name
      this.updateId = row.id
      this.dialog2 = true
    },

    deleteMsg(id) {
      this.$confirm('此操作将永久删除该文件, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        this.deleteId = id
        this.$http
          .post('axh/newType/deleteById', {
            id: this.deleteId,
          })
          .then((res) => {
            this.getDetail()
          })
        this.$message({
          type: 'success',
          message: '删除成功!'
        });
      }).catch(() => {
        this.$message({
          type: 'info',
          message: '已取消删除'
        });
      });

    },
    add1() {
      this.dialog = false
      if (!this.titleName) {
        this.$message.error('标题名称不能为空')
      } else {
        this.$http
          .post('axh/newType/createType', {
            pid: this.id,
            name: this.titleName,
            type: this.radio,
            isValid: 1,
          })
          .then((res) => {
            this.getDetail()
            this.titleName = ''
          })
      }
    },
  },
}
</script>
<style lang="scss" scoped>
.mmmmmmggg {
  margin: 20px;

  .screenComp {
    background-color: $bgColorFFFFFF;
    padding: 12px 16px;
    margin-bottom: 20px;
    border-radius: 5px;
    min-height: 120px;
  }

  .highlight {
    color: #2c83e4 !important; // 高亮背景色
    font-weight: 700 !important;
  }

  .body1 {
    margin-top: 19px;
    margin-left: 22px;
    width: 97%;
    height: 689px;
    background: white;
    position: relative;

    .button2 {
      margin-left: 24px;
      margin-top: 24px;
      color: #666666;
      width: 65px;
      height: 21px;
      font-size: 16px;
      font-family: Microsoft YaHei-Bold, Microsoft YaHei;
      font-weight: 400;
      line-height: 21px;
    }
  }

  .header {
    position: relative;
    width: 100%;
    height: 168px;
    background: #ffffff;


    .title1 {
      top: 29px;
      left: 16px;
      color: #2c83e4;
      font-size: 24px;
      font-weight: 700;
      display: block;
      position: absolute;
    }

    .search {
      position: relative;
      height: 54px;
      top: 103px;
      left: 16px;

      .areaSearch {
        position: absolute;
        left: 365px;
        top: 10px;
      }

      .typeChoose {
        position: absolute;
        left: 400px;
        // height: 40px;
        width: 136px;

      }
    }
  }

  .appMessagePage {
    margin: 22px 0;
    padding: 10px;
    background-color: $bgColorFFFFFF;
    border-radius: 4px;

    .custom-tabs-label {
      display: flex;
      align-items: center;

      .tableCol {
        font-size: 16px;
        margin-right: 8px;
      }

      .tableTips {
        display: inline-block;
        border-radius: 20px;
        padding: 0 5px;
        font-size: 12px;
        height: 17px;
        line-height: 18px;
        color: $colorFFFFFF;
        transform: translateY(-1px);
      }
    }

    .tabContent {
      width: 100%;
      background-color: $bgColorFFFFFF;
      border-radius: 4px;

      .spanBtn {
        cursor: pointer;
      }
    }
  }
}
</style>